package hk.m4s.lr.repair.test.service.address;

import android.content.Context;

import java.util.Map;

import framework.common.widgets.dialogs.UeDialog;
import framework.common.zanetwork.UeHttpUrl;
import framework.common.zanetwork.core.HttpCallback;
import framework.common.zanetwork.core.ResponseCallback;
import hk.m4s.lr.repair.test.model.AddressModel;
import hk.m4s.lr.repair.test.model.AddressModelResult;
import hk.m4s.lr.repair.test.model.UserinfoModel;
import hk.m4s.lr.repair.test.service.BaseService;
import okhttp3.Response;

/**
 * Created by qi.wang on 2017/4/1.
 */

public class AddressService extends BaseService{
    public static void expressAddressList (final Context context, Map<String, Object> parmas, final ResponseCallback<AddressModelResult> callback) {

        httpHelper.post(UeHttpUrl.expressAddressList(), parmas, new HttpCallback<AddressModelResult>() {
            @Override
            public void onRequestBefore() {

            }

            @Override
            public void onSuccess(Response response, AddressModelResult o) {

                callback.onSuccess(o);
            }

            @Override
            public void onError(Response response, int errorCode, Exception e) {

                callback.onError(response, errorCode, null, e);

            }

            @Override
            public void onFailure(Response response, String failureMsg, int code) {

                callback.onError(response, code, failureMsg, null);
            }
        });
    }
    public static void expressAddressAdd (final Context context, Map<String, Object> parmas, final ResponseCallback<AddressModel> callback) {

        httpHelper.post(UeHttpUrl.expressAddressAdd(), parmas, new HttpCallback<AddressModel>() {
            @Override
            public void onRequestBefore() {
                UeDialog.showprogressDialog(context,"","添加中...",false);
            }

            @Override
            public void onSuccess(Response response, AddressModel o) {
                UeDialog.hideProgress();
                callback.onSuccess(o);
            }

            @Override
            public void onError(Response response, int errorCode, Exception e) {
                UeDialog.hideProgress();
                callback.onError(response, errorCode, null, e);

            }

            @Override
            public void onFailure(Response response, String failureMsg, int code) {
                UeDialog.hideProgress();
                callback.onError(response, code, failureMsg, null);
            }
        });
    }
    public static void expressAddressState (final Context context, Map<String, Object> parmas, final ResponseCallback<AddressModel> callback) {

        httpHelper.post(UeHttpUrl.expressAddressState(), parmas, new HttpCallback<AddressModel>() {
            @Override
            public void onRequestBefore() {
                UeDialog.showprogressDialog(context,"","修改中...",false);
            }

            @Override
            public void onSuccess(Response response, AddressModel o) {
                UeDialog.hideProgress();
                callback.onSuccess(o);
            }

            @Override
            public void onError(Response response, int errorCode, Exception e) {
                UeDialog.hideProgress();
                callback.onError(response, errorCode, null, e);

            }

            @Override
            public void onFailure(Response response, String failureMsg, int code) {
                UeDialog.hideProgress();
                callback.onError(response, code, failureMsg, null);
            }
        });
    }
    public static void expressAddressDel (final Context context, Map<String, Object> parmas, final ResponseCallback<AddressModel> callback) {

        httpHelper.post(UeHttpUrl.expressAddressDel(), parmas, new HttpCallback<AddressModel>() {
            @Override
            public void onRequestBefore() {
                UeDialog.showprogressDialog(context,"","修改中...",false);
            }

            @Override
            public void onSuccess(Response response, AddressModel o) {
                UeDialog.hideProgress();
                callback.onSuccess(o);
            }

            @Override
            public void onError(Response response, int errorCode, Exception e) {
                UeDialog.hideProgress();
                callback.onError(response, errorCode, null, e);

            }

            @Override
            public void onFailure(Response response, String failureMsg, int code) {
                UeDialog.hideProgress();
                callback.onError(response, code, failureMsg, null);
            }
        });
    }
}
